﻿using System;
using System.Data;
using OA.Manager;
using OA.Model;


namespace OA.Web
{
    public partial class ToExecl : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Web.UI.Page page = this.Page;
            page.Response.Clear();
            page.Response.Buffer = true;
            page.Response.Charset = "gbk";
            string name =System.DateTime.Now.ToString("yyMMddHHmmss") + ".xls";
            page.Response.AppendHeader("Content-Disposition", "attachment;filename=" + name);
            page.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");//设置输出流为简体中文
            page.Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
            page.EnableViewState = false;
            ManagerParent<EmployeeInfo> Manager = new ManagerParent<EmployeeInfo>();
            int total = 0;
            DataTable dt = Manager.GetSearchPaged("", 1, 20, ref total);
            page.Response.Write(OA.Utility.ToExecl .ExportTable(dt));
            page.Response.End();
            Response.Redirect("DownloadWord.aspx?id=" + name);
        }
    }
}
